/*
Copyright 2010 Farent-Solutions Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

 */
package com.farent.solutions.plugins.aribaweb.awl.completion;

import java.io.InputStream;
import java.util.Collection;
import org.netbeans.modules.xml.schema.model.SchemaModel;
import org.netbeans.modules.xml.schema.model.SchemaModelFactory;
import org.netbeans.modules.xml.xam.ModelSource;
import org.netbeans.modules.xml.xam.dom.AbstractDocumentModel;
import org.netbeans.spi.editor.completion.CompletionItem;
import org.openide.util.lookup.Lookups;

/**
 *
 * @author farouka
 */
public class AWCoreCompletionProvider implements AwlCompletion {

    @Override
    public Collection<? extends CompletionItem> getResults() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public SchemaModel createMetaSchemaModel() {
        try {
            InputStream in = getClass().getResourceAsStream("a-api.xsd"); //NOI18N
            javax.swing.text.Document d = AbstractDocumentModel.getAccessProvider().loadSwingDocument(in);
            ModelSource ms = new ModelSource(Lookups.singleton(d), false);
            SchemaModel m = SchemaModelFactory.getDefault().createFreshModel(ms);
            m.sync();
            return m;
        } catch (Exception ex) {
            //just catch
        }
        return null;
    }
}
